package com.review.Demo_5_锁的其他概念;
/**
 * synchronized异常：是否继续执行----其实有没有锁都没有关系
 * @author alienware
 *
 */
public class Sync_3_锁异常 {

	private int i = 0;
	public synchronized void operation(){
		while(true){
			try {
				i++;
				Thread.sleep(100);
				System.out.println(Thread.currentThread().getName() + " , i = " + i);
				if(i == 10){
					Integer.parseInt("a");
				}
				
			//会结束循环
//			} catch (InterruptedException e) {
//				e.printStackTrace();
//			}
			
			//会继续循环
			} catch (Exception e) {
				e.printStackTrace();
				//throw new RuntimeException(); //会结束
			}
		}
	}
	
	public static void main(String[] args) {
		final Sync_3_锁异常 se = new Sync_3_锁异常();
		Thread t1 = new Thread(new Runnable() {
			public void run() {
				se.operation();
			}
		},"t1");
		t1.start();
	}
	
	
}
